﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TecData.Interfaces;
using TecData.Layer;
using TecData.Properties;

namespace TecData.Manager {

    public static class DataManager {

        public static IDataLayer CreateDataLayer(Type type) {
            return CreateDataLayer(type, null);
        }

        public static IDataLayer CreateDataLayer(Type type, string connectionString) {
            IDataLayer datalayer = (Activator.CreateInstance(type) as IDataLayer);
            Type tec = typeof(TecNotizDataLayer);
            if (datalayer != null) {
                if (connectionString != null) {
                    datalayer.Initialize(connectionString);
                } else {
                    datalayer.Initialize(Settings.Default.SQL_Server_ConnectionString);
                }
            }
            return datalayer;
        }

    }
}
